﻿namespace Blaze.Framework.MonoEventListeners
{
    using UnityEngine;

    public class Renderer : MonoBehaviour
    {
        public event EventHandler OnBecameInvisibleEvent;

        public event EventHandler OnBecameVisibleEvent;

        public static Renderer Get(GameObject obj)
        {
            return obj.GetOrAddComponent<Renderer>();
        }

        private void OnBecameInvisible()
        {
            if (OnBecameInvisibleEvent != null)
                OnBecameInvisibleEvent(gameObject);
        }

        private void OnBecameVisible()
        {
            if (OnBecameVisibleEvent != null)
                OnBecameVisibleEvent(gameObject);
        }
    }
}